import collections


class Solution:
    def canConvert(self, str1: str, str2: str) -> bool:
        if str1 == str2:
            return True

        change_out = collections.defaultdict(set)
        change_in = set()
        for i in range(len(str1)):
            ch1 = str1[i]
            ch2 = str2[i]
            change_out[ch1].add(ch2)
            change_in.add(ch2)
            if len(change_out[ch1]) > 1:
                return False
        return len(change_out) <= 25 or len(change_in) <= 25


if __name__ == "__main__":
    print(Solution().canConvert(str1="aabcc", str2="ccdee"))  # True
    print(Solution().canConvert(str1="leetcode", str2="codeleet"))  # False

    # 测试用例36/40
    print(Solution().canConvert("abcdefghijklmnopqrstuvwxyz", "bcdefghijklmnopqrstuvwxyza"))  # False
